/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ws;

import dao.RemoteGestHotel;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import model.Chambre;
import model.Client;
import model.Reservation;
import model.TypeChambre;

/**
 *
 * @author taha
 */
@WebService
public class WebServiceHotel {

    @EJB
    private RemoteGestHotel hotel;

    @WebMethod(operationName = "liste_chambre_by_type")
    public List<Chambre> liste_chambre_by_type(@WebParam(name = "type_chambre") int type_chambre) {
        return hotel.liste_chambre_by_type(type_chambre);
    }

    @WebMethod(operationName = "getTypes")
    public List<TypeChambre> getTypes() {
        return hotel.getTypes();
    }

    @WebMethod(operationName = "dispoChambre")
    public boolean dispoChambre(@WebParam(name = "id_chambre") int id_chambre) {
        return hotel.dispoChambre(id_chambre);
    }

    @WebMethod(operationName = "reserveChambre")
    public Client reserveChambre(@WebParam(name = "num_compte") Long num_compte, @WebParam(name = "id_chambre") int id_chambre, @WebParam(name = "debut") String debut, @WebParam(name = "fin") String fin) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
        Date d = sdf.parse(debut);
        Date f = sdf.parse(fin);
        return hotel.reserveChambre(num_compte, id_chambre, d, f);
    }

    @WebMethod(operationName = "liste_reservation_by_type")
    public List<Reservation> liste_reservation_by_type(@WebParam(name = "type_chambre") int type_chambre) {
        return hotel.liste_reservation_by_type(type_chambre);
    }
}
